package com.awardsystem.Service;

import com.awardsystem.Dao.AchievementDao;
import com.awardsystem.entity.Achievement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AchievementService {
    @Autowired
    AchievementDao achievementDao;

    public void addAchievement(Achievement achievement){achievementDao.save(achievement);}
    public void deleteAchievement(Achievement achievement){achievementDao.delete(achievement);}
    public void deleteAchievementById(int id){achievementDao.deleteById(id);}
    public List<Achievement> findAchievementAll(){return achievementDao.findAll();}

    public Achievement findAchievementByName(String name){return achievementDao.findAchievementByName(name);}
    public Achievement findAchievementById(int id){return achievementDao.findAchievementById(id);}
    public Page<Achievement> getAchievementPage(PageRequest page){return achievementDao.findAll(page);}

    public void deleteRelatedUser(int aid,int uid){ achievementDao.deleteAchievementUser(aid,uid);}
    public void deleteRelatedPatent(int aid,int pid){ achievementDao.deleteAchievementPatent(aid,pid);}
    public void deleteRelatedSCI(int aid,int sid){ achievementDao.deleteAchievementSCI(aid,sid);}

    public void addRelatedUser(int aid,int uid){ achievementDao.insertAchievementUser(aid,uid);}
    public void addRelatedPatent(int aid,int pid){ achievementDao.insertAchievementPatent(aid,pid);}
    public void addRelatedSCI(int aid,int sid){ achievementDao.insertAchievementSCI(aid,sid);}

    public void save(Achievement achievement){achievementDao.save(achievement);}
}
